package org.bsplus.rpc.impl;

import java.util.List;

import javax.annotation.Resource;

import org.bsplus.domain.User;
import org.bsplus.rpc.UserRPCService;
import org.bsplus.rpc.dto.UserDTO;
import org.bsplus.service.UserService;
import org.bsplus.util.MappingUtils;
import org.springframework.beans.factory.annotation.Required;

public class UserRPCServiceImpl implements UserRPCService
{
	private UserService userService;

	private MappingUtils mappingUtils;

	@Resource
	@Required
	public void setUserService(UserService userService)
	{
		this.userService = userService;
	}

	@Resource
	@Required
	public void setMappingUtils(MappingUtils mappingUtils)
	{
		this.mappingUtils = mappingUtils;
	}

	@Override
	public List<UserDTO> getAllUsers()
	{
		List<User> users = userService.getAllUsers();

		return mappingUtils.map(users, UserDTO.class);
	}
}
